<?php

use yii\helpers\Html;
use kartik\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\modules\sysConfig\models\search\SmstemplateSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '定制短信模板';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="smstemplate-index">

    <?php echo $this->render('_searchsms', ['model' => $searchModel]); ?>

    <p>
    </p>

    <?=
    GridView::widget([
        'dataProvider' => $dataProvider,
        'responsive' => true,
        'hover' => true,
        'pjax' => true,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\RadioButtonColumn'],
            'smstempltpk',
            'type',
            'content',
//            'createtime',
//            'createuser',
//            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]);
    ?>

</div>
<?php
$js = <<< JS
        $("input[type=radio]").change(function(){
            var value = $(this).val();
        $.ajax({
             url: "/sysConfig/smstemplate/alljosn",              //请求地址
             type: "POST",                       //请求方式
             data: {id: value,_csrf:$('meta[name="csrf-token"]').attr("content")}, //请求参数
             dataType: "json",
                     success: function (data) {
                         if (data.status === 'success') {
                         // 此处放成功后执行的代码
                          window.parent.document.getElementById('cust-btn-ok').setAttribute('attrs',data.contens);
                         } else {
                             alert(data.message);
                         }
                     },
                  });
             });
JS;

// register javascript
$this->registerJs($js);
?>
